package com.tv.cms.system.operator.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.tv.cms.system.admin.model.Admin;
import com.tv.cms.system.admin.service.AdminService;
import com.tv.cms.system.operator.mapper.OperatorMapper;
import com.tv.cms.system.operator.model.Operator;
import com.tv.cms.system.operator.service.OperatorService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * TODO
 *
 * @author
 * @date
 **/
@Service
public class OperatorServiceImpl extends MPJBaseServiceImpl<OperatorMapper, Operator> implements OperatorService {

    @Resource
    private AdminService adminService;
    /**
     * 授权码销售数据权限
     * @param id
     * @return
     */
    @Override
    public void dataList(StringBuffer operatorIds, Integer id) {
        List<Operator> operatorList = list(new QueryWrapper<Operator>().eq("create_by", id));
        for (Operator operator : operatorList) {
            operatorIds.append(operator.getId()).append(",");
            List<Admin> adminList = adminService.list(new QueryWrapper<Admin>().eq("operator_id",operator.getId()));
            for (Admin admin : adminList) {
                dataList(operatorIds,admin.getId());
            }
        }
    }
}
